package cn.dw.service.impl;

import cn.dw.dao.UserDao;
import cn.dw.domain.User;
import cn.dw.service.Userservice;

public class UserServiceImpl
  implements Userservice
{
  private UserDao ud;
  
  public User login(User u)
  {
    User user = this.ud.getByUserName(u.getUsername());
    if (user == null) {
      throw new RuntimeException("用户名不存在!");
    }
    if (!u.getPassword().equals(user.getPassword())) {
      throw new RuntimeException("密码不正确!");
    }
    return user;
  }
  
  public void setUd(UserDao ud)
  {
    this.ud = ud;
  }
}
